package com.wf.mock.app.mina.app.processor.impl;

import org.apache.mina.core.session.IoSession;

import com.wf.mock.app.mina.app.processor.IMessageProcessor;
import com.wf.mock.app.mina.dto.RawMessageDTO;

public class MainMessageProcessorImpl implements IMessageProcessor {

	private final static IMessageProcessor instance = new MainMessageProcessorImpl();

	public final static IMessageProcessor getInstance() {
		return instance;
	}

	@Override
	public void process(RawMessageDTO msgDto, IoSession session) {

		try {
			IMessageProcessor realProcessor = (IMessageProcessor) msgDto.getType().getProcessorClazz().newInstance();
			realProcessor.process(msgDto, session);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
